{% extends "../base.html" %}

{% block head %}
  <link rel="stylesheet" type="text/css" href="{{ static_url('css/secret.css') }}">
{% end %}

{% block body %}
  <div class="container">
    <form class="form-signin" action='{{ request.path }}' method='POST'>
      <h2 class="form-signin-heading">忘记密码</h2>
      <label class="sr-only">新密码</label>
      <input class="form-control" type='password' id='new_pass' name='new_pass' placeholder="新密码" required autofocus/>
      <label class="sr-only">确认新密码</label>
      <input class="form-control" type='password' id='password-confirm' placeholder="确认新密码" required/>
      <input type="hidden" name="email" value="{{ email }}"/>
      {% module xsrf_form_html() %}
      <span id="notify"></span>
      <button class="btn btn-lg btn-primary btn-block" type="submit">更改</button>
    </form>
  </div>
{% end %}

{% block bottom%}
  <script type="text/javascript">
    $("button").click(function () {
      if (!passwordConfirmation("#new_pass", "#password-confirm")) {
        $("#notify").html('<div class="alert alert-danger">'
                          + '<button class="close" data-dismiss="alert">&times;</button>'
                          + '两次输入密码不一致！'
                          + '</div>');
      } else {
        $("form").submit();
      }
    });
  </script>
{% end %}
